package com.sg.hms.ServiceImpl;

import net.sf.json.JSONArray;

import java.util.List;

import com.sg.hms.Dao.EmployeeDao;
import com.sg.hms.DaoImpl.EmployeeDaoImpl;
import com.sg.hms.Model.Employee;
import com.sg.hms.Service.EmployeeService;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class EmployeeServiceImpl implements EmployeeService{

	private EmployeeDao emDao=new EmployeeDaoImpl();
    @Override
	public Employee selectEmployeeByElId(int elId) {
		// TODO Auto-generated method stub
		return emDao.selectEmployeeByElId(elId);
	}
    //根据部门返回其下面的员工
	@Override
	public JSONArray selectEmployeeBydName(String dName) {
		// TODO Auto-generated method stub
		return emDao.selectEmployeeBydName(dName);
	}
	@Override
	public JSONObject selectEmloyeeByGroup(int start, int rows) {
		// TODO Auto-generated method stub
		JSONObject em=new JSONObject();
		em.put("total", emDao.selectEmployeeCount());
		em.put("rows", JSONArray.fromObject(emDao.selectEmployeeByGroup(start,rows)));
		return em;
	}
	@Override
	public JSONObject selectEmloyeeByGroup(int start, int rows, String searchName) {
		// TODO Auto-generated method stub
		JSONObject em=new JSONObject();
		em.put("total", emDao.selectEmployeeCount(searchName));
		em.put("rows", JSONArray.fromObject(emDao.selectEmployeeByGroup(start, rows, searchName)));
		return em;
	}
	@Override
	public int addEmpl(Employee em) {
		// TODO Auto-generated method stub
		return emDao.addEmployee(em);
	}
	@Override
	public int upEmpl(Employee em) {
		// TODO Auto-generated method stub
		return emDao.upEmployee(em);
	}
	@Override
	public int delEmpl(int elId) {
		// TODO Auto-generated method stub
		return emDao.delEmployee(elId);
	}
	@Override
	public JSONObject sortEmpl(String sort, String order, int start, int rows) {
		// TODO Auto-generated method stub
		JSONObject em=new JSONObject();
		em.put("total", emDao.selectEmployeeCount());
		em.put("rows", JSONArray.fromObject(emDao.SortEmpl(sort, order, start, rows)));
		return em;
	}
	@Override
	public int personalUp(Employee em) {
		// TODO Auto-generated method stub
		return emDao.personalUp(em);
	}
	@Override
	public JSONObject SortEmpl(String searchName, String sort, String order, int start, int rows) {
		// TODO Auto-generated method stub
		JSONObject em=new JSONObject();
		em.put("total", emDao.selectEmployeeCount(searchName));
		em.put("rows", JSONArray.fromObject(emDao.SortEmpl(searchName, sort, order, start, rows)));
		return em;
	}

}
